//
//  ViewController.m
//  1507图片换页
//
//  Created by 小白 on 16/2/20.
//  Copyright © 2016年 小白. All rights reserved.
//

#import "ViewController.h"

@interface ViewController ()


@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
    index = 0;
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}
-(void)changeImage:(int)index
{
        NSArray *Arr = [NSArray arrayWithObjects:@"biaoqingdi",@"bingli",@"chiniupa",@"danteng",@"wangba", nil];
        NSArray *value = [NSArray arrayWithObjects:@"biaoqingdi",@"bingli",@"chiniupa",@"danteng",@"wangba", nil];
        UIImage *img = [UIImage imageNamed:[Arr objectAtIndex:index]];
        self.image.image = img;
        self.labelexplain.text = [value objectAtIndex:index];
        self.labeltoppage.text = [NSString stringWithFormat:@"%d",index];
}


- (IBAction)btnrightpic:(id)sender {
//    NSArray *Arr = [NSArray arrayWithObjects:@"biaoqingdi",@"bingli",@"chiniupa",@"danteng",@"wangba", nil];
//    NSArray *value = [NSArray arrayWithObjects:@"biaoqingdi",@"bingli",@"chiniupa",@"danteng",@"wangba", nil];
//    int i=2;
//    UIImage *img = [UIImage imageNamed:[Arr objectAtIndex:i]];
//    self.image.image = img;
//    self.labelexplain.text = [value objectAtIndex:i];
//    self.labeltoppage.text = [NSString stringWithFormat:@"%d",i];
//    NSString *plistpath = [[NSBundle mainBundle]pathForResource:@"imageData" ofType:@"plist"];
////    NSMutableArray *mArr = [NSMutableArray arrayWithContentsOfFile:plistpath];
//    NSMutableDictionary *mDic = [NSMutableDictionary dictionaryWithContentsOfFile:plistpath];
    index++;
    if (index>4) {
        self.labelexplain.text = @"这已经是最后一页了";
        index = 4;
        self.btnRightpic.hidden = YES;
    }
    else {
        [self changeImage:index];
        self.btnleftpic.hidden = NO;
    }
    
    
    
    
//    for (NSString *i in mArr) {
//        NSLog(@"%@",i);
//    }
}
- (IBAction)btnleftpic:(id)sender {
    index--;
    if (index<0) {
        self.labelexplain.text = @"这已经是最后一页了";
        index = 0;
        self.btnleftpic.hidden = YES;
    }
    else {
        [self changeImage:index];
        self.btnRightpic.hidden = NO;
    }
    

}
@end
